package com.team.service.impl;

import com.team.dto.TeamPageQueryDTO;
import com.team.entity.Team;
import com.team.entity.TeamDetails;
import com.team.mapper.TeamMapper;
import com.team.service.TeamService;
import com.team.vo.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeamServiceImpl implements TeamService {

    @Autowired
    private TeamMapper teamMapper;

    @Override
    public PageResult page(TeamPageQueryDTO teamPageQueryDTO) {
        PageHelper.startPage(teamPageQueryDTO.getPage(), teamPageQueryDTO.getPageSize());
        Page<Team> res = teamMapper.page(teamPageQueryDTO);
        return new PageResult(res.getTotal(), res.getResult());
    }

    @Override
    public List<Team> getAll() {
        return teamMapper.getAll();
    }

    @Override
    public TeamDetails getTeamDetails(Integer tid) {
        return teamMapper.getTeamDetails(tid);
    }
}
